package cool.lichuan.project.system.controller;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import cool.lichuan.common.domain.Result;
import cool.lichuan.project.common.BaseController;
import cool.lichuan.project.system.dto.ConfigVO;
import cool.lichuan.project.system.dto.CustInfo;
import cool.lichuan.project.system.dto.HeaderInfo;
import cool.lichuan.project.system.service.VaccineService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lichuan
 * @date 2021/11/24 16:08
 * @description
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/yimiao")
public class VaccineController extends BaseController {
    private final VaccineService vaccineService;
    @Autowired
    private CustInfo custInfo;

    @Autowired
    private HeaderInfo headerInfo;

    @GetMapping("/test")
    public Result<Object> testConnection() {
        return Result.success(vaccineService.testConnect());
    }

    @GetMapping("/getUserInfo")
    public Result<Object> getUserInfo() {
        return Result.success(JSONUtil.toJsonStr(vaccineService.getUserInfo()));
    }

    @PostMapping("/updateHeader")
    public Result<Object> updateHeader(@RequestBody ConfigVO headerInfo) {
        return Result.success(vaccineService.updateHeaderInfo(headerInfo));
    }


    @GetMapping("/seckillVaccine")
    public Result<Object> seckillVaccine() {
        return Result.success(vaccineService.seckillVaccine());
    }
    @GetMapping("/decodeDateDetail")
    public Result<Object> decodeDateDetail(String text) {
        return Result.success(vaccineService.decodeDateDetail(text));
    }

    @GetMapping("/getConfig")
    public Result<ConfigVO> getConfig(){
        return Result.success(vaccineService.getConfig());
    }
    @GetMapping("/getSubList")
    public Result<String> getSubList(){
        return Result.success(vaccineService.getSubList());
    }





}
